package com.example.Announcement.controller;

import com.example.Announcement.domain.Announcement;
import com.example.Announcement.service.IAnnouncementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/announcement")
@Api(value="announcement",tags="公告管理")
public class AnnouncemnetController {
    @Autowired
    private IAnnouncementService iAnnouncementService;

    @GetMapping("/getAnnouncementList")
    @ApiOperation("查询公告")
    public List<Announcement> getAnnouncementList(Announcement announcement){
        List<Announcement> list = iAnnouncementService.selectAnnouncement(announcement);
        return  list;
    }

    @PostMapping("/addAnnouncement")
    @ApiOperation("增加公告")
    public Announcement addAnnouncement(@RequestBody Announcement announcement){
        iAnnouncementService.insertAnnouncement(announcement);
        return announcement;
    }

    @PostMapping("/updateAnnouncementById")
    @ApiOperation("修改公告")
    public  String updateAnnouncementById(@RequestBody Announcement announcement){
        iAnnouncementService.updateAnnouncementById(announcement);
        return "修改成功";
    }

    @DeleteMapping("/delAnnouncementById")
    @ApiOperation("删除公告")
    public  String delAnnouncementById (String announcementId){
        iAnnouncementService.delAnnouncementById(announcementId);
        return  "删除成功";
    }
}
